****TABLE 5****

cd "$main_dir/output/tables/main"

global basic 	marital edu
global econ	    employment_status occupation income imputed_income
global design 	survey_year age language
global polit    ideology party_member

//--------------------------------------------------------
//Read in relevant datasets
//--------------------------------------------------------

clear
use "$data_dir/clean/shp_final_panel.dta"

xtset idpers survey_year

gen dummy = 1 if trust_fed_govt_med!=.
bys idpers: egen total_obs = total(dummy)

cap drop sample income_sample
gen sample = 1 if live_switz==1 & total_obs>4 & total_obs!=. & age>=15 & age!=.
gen income_sample = 1 if live_switz==1 & total_obs>4 & total_obs!=. & age>=18 & age!=. & total_real_income_with_0_obs>=0.5*(age-18) & total_real_income_with_0_obs!=.

egen canton_survey_year = group(canton survey_year)

//--------------------------------------------------------
//Create Table 5
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med wgrowth_rate_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_5.doc, replace dec(3) nocons addtext(Individual FE, Yes, ///
													   Canton FE, Yes, ///
													   Survey Year FE, Yes, ///
													   Canton FE x Survey Year FE, No) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 
//results interpretation
summ wgrowth_rate_1 if e(sample)==1
summ trust_fed_govt_med if e(sample)==1
di _b[zwgrowth_rate_1]*r(sd)

//Column 2
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med wgrowth_rate_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
													   Canton FE, No, ///
													   Survey Year FE, No, ///
													   Canton FE x Survey Year FE, Yes) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1)
													   

//Column 3
qui reghdfe trust_fed_govt_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton $basic $design employment_status occupation imputed_income $polit idpers) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med wgrowth_rate_1 wincome_growth_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton $basic $design employment_status occupation imputed_income $polit idpers) cluster(idhous yob)
outreg2 using table_5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
													   Canton FE, Yes, ///
													   Survey Year FE, Yes, ///
													   Canton FE x Survey Year FE, No) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1)

//Column 4
qui reghdfe trust_fed_govt_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton_survey_year $basic $design employment_status occupation imputed_income $polit idpers) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med wgrowth_rate_1 wincome_growth_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton_survey_year $basic $design employment_status occupation imputed_income $polit idpers) cluster(idhous yob)
outreg2 using table_5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
													   Canton FE, No, ///
													   Survey Year FE, No, ///
													   Canton FE x Survey Year FE, Yes) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1)

//Column 5
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
cap drop z*
local varlist trust_others_med wgrowth_rate_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1, absorb(canton $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
													   Canton FE, Yes, ///
													   Survey Year FE, Yes, ///
													   Canton FE x Survey Year FE, No) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 6
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
cap drop z*
local varlist trust_others_med wgrowth_rate_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1, absorb(canton_survey_year $basic $design $econ $polit idpers) cluster(idhous yob)
outreg2 using table_5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
													   Canton FE, No, ///
													   Survey Year FE, No, ///
													   Canton FE x Survey Year FE, Yes) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1) 

//Column 7
qui reghdfe trust_others_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton $basic $design employment_status occupation imputed_income $polit idpers) cluster(idhous yob)
cap drop z*
local varlist trust_others_med wgrowth_rate_1 wincome_growth_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_others_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton $basic $design employment_status occupation imputed_income $polit idpers) cluster(idhous yob)
outreg2 using table_5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
													   Canton FE, Yes, ///
													   Survey Year FE, Yes, ///
													   Canton FE x Survey Year FE, No) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1)

//Column 8
qui reghdfe trust_others_med wgrowth_rate_1 wincome_growth_1 if income_sample==1, absorb(canton_survey_year $basic $design employment_status occupation imputed_income $polit idpers) cluster(idhous yob)
cap drop z*
local varlist trust_others_med wgrowth_rate_1 wincome_growth_1
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_others_med zwgrowth_rate_1 zwincome_growth_1 if e(sample)==1, absorb(canton_survey_year $basic $design employment_status occupation imputed_income $polit idpers) cluster(idhous yob)
outreg2 using table_5.doc, append dec(3) nocons addtext(Individual FE, Yes, ///
													   Canton FE, No, ///
													   Survey Year FE, No, ///
													   Canton FE x Survey Year FE, Yes) addstat("No. of Respondents", `=e(df_a_nested)') keep(zwgrowth_rate_1 zwincome_growth_1)

